<template>
  <div style="height: 100%; width: 100%; position: relative;" ref="maindev">
      <div class="pagetop">
          <div style="width:100%;">
              <table style="width: 100%; font-size: 12px;white-space: nowrap;" border="0">
                  <col style="width: 5%;" />
                  <col style="width: 11%;" />
                  <col style="width: 1%;" />
                  <col style="width: 11%;" />
                  <col style="width: 5%;" />
                  <col style="width: 9%;" />
                  <col style="width: 5%;" />
                  <col style="width: 8%;" />
                  <col style="width: 5%;" />
                  <col style="width: 8%;" />
                  <col style="width: 6%;" />
                  <col style="width: 9%;" />
                  <col style="width: 6%;" />
                  <col style="width: 9%;" />
                  <tr>
                      <td align="right">
                          <el-dropdown @command="handleCommand" style="font-size:12px">
                              <u class="el-dropdown-link">
                                  {{datename}}
                              </u>
                              <el-dropdown-menu slot="dropdown">
                                  <el-dropdown-item command="接收日期">
                                      <font font-size="12px">接收日期</font>
                                  </el-dropdown-item>
                                  <el-dropdown-item command="报告日期">
                                      <font font-size="12px">报告日期</font>
                                  </el-dropdown-item>
                                  <el-dropdown-item command="工作组签收日期">
                                      <font font-size="12px">工作组签收日期</font>
                                  </el-dropdown-item>
                              </el-dropdown-menu>
                          </el-dropdown>
                      </td>
                      <td>
                          <el-date-picker v-model="searchobj.strdate" :clearable="false" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
                      </td>
                      <td>至</td>
                      <td>
                          <el-date-picker v-model="searchobj.enddate" type="date" :clearable="false" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
                      </td>
                      <td align="right">送检医院</td> 
                      <td>
                          <el-select v-model="searchobj.hospcode" @dblclick.native="popMultipleChk(searchobj.hospcode,'hospcode',hospOption,'请选择送检医院')" filterable clearable style="width:100%">
                              <el-option v-for="(item,index) in hospOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right">检验医生</td>
                      <td>
                          <rm-ddl-common datatype="userinfo" kindno="1" dataname="检验医生" v-model="searchobj.reportusername" width="100%" @change="reportuserChange"></rm-ddl-common>
                      </td>
                      
                      <td align="right">送检医生</td>
                      <td>
                          <rm-ddl-common datatype="doctor" dataname="送检医生" v-model="searchobj.reqdocno" width="100%" @change="reqdocChange"></rm-ddl-common>
                      </td>


                      <td align="right">病人类型</td>
                      <td>
                          <el-select v-model="searchobj.pattype" filterable clearable @dblclick.native="popMultipleChk(pattype, 'pattype', pattypeOption, '病人类型选择')" ref="refpattype" @keyup.enter.native="selectBlur('pattype','refpattype',pattypeOption)" style="width:100%">
                              <el-option v-for="(item, index) in pattypeOption" :value="item.data" :label="item.display" :key="index"> <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">申请单状态</td>
                      <td>
                          <el-select v-model="searchobj.reqstat" style="width:100%" filterable clearable>
                              <el-option value="0" label="申请"></el-option>
                              <el-option value="1" label="打印"></el-option>
                              <el-option value="12" label="打印复核"></el-option>
                              <el-option value="2" label="采样"></el-option>
                              <el-option value="3" label="护士站送出"></el-option>
                              <el-option value="31" label="已下载"></el-option>
                              <el-option value="4" label="检验科签收"></el-option>
                              <el-option value="41" label="工作组签收"></el-option>
                              <el-option value="42" label="上机"></el-option>
                              <el-option value="43" label="组内交接"></el-option>
                              <el-option value="44" label="已分样"></el-option>
                              <el-option value="45" label="外送送出"></el-option>
                              <el-option value="01" label="申请单已被审核"></el-option>
                              <el-option value="02" label="申请单审核未通过"></el-option>
                              <el-option value="03" label="复审通过"></el-option>
                              <el-option value="04" label="复审未通过"></el-option>
                          </el-select>
                      </td>
                      <!-- <td align="right">检验组别</td>
                      <td>
                          <el-select v-model="searchobj.labgroupid" style="width: 100%;" filterable clearable ref="reflabgroupid" @keyup.enter.native="selectBlur('labgroupid','reflabgroupid',labgroupOption)">
                              <el-option v-for="(item, index) in labgroupOption" :key="index" :label="item.display" :value="item.data">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td> -->
                      
                      
                      
                  </tr>
                  <tr>
                      <td align="right">报告单元</td>
                      <td colspan="3">
                          <el-select v-model="searchobj.rptunitid" @dblclick.native="popMultipleChk(searchobj.rptunitid, 'rptunitid', rptunitOption, '请选择报告单元')" ref="refrptunitid" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('rptunitid','refrptunitid',rptunitOption)">
                              <el-option v-for="(item, index) in rptunitOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">申请科室</td>
                      <td>
                          <el-select v-model="searchobj.reqdeptno" @dblclick.native="popMultipleChk(searchobj.reqdeptno,'reqdeptno',deptOption,'申请科室选择')" filterable clearable>
                              <el-option v-for="(item,index) in deptOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">执行科室</td>
                      <td>
                          <rm-ddl-common datatype="dept" kindno="perform" dataname="科室" v-model="searchobj.performdept" width="100%" @change="performdeptChange"></rm-ddl-common>
                      </td>
                      <!-- <td align="right">分单类别</td>
                      <td>
                          <el-select v-model="searchobj.req_groupid" @dblclick.native="popMultipleChk(searchobj.req_groupid, 'req_groupid', reqgroupOption, '请选择分单类别')" ref="refreq_groupid" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('req_groupid','refreq_groupid',reqgroupOption)">
                              <el-option v-for="(item, index) in reqgroupOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td> -->
                      
                      <td align="right">性别</td>
                      <td>
                          <el-select v-model="searchobj.patsex" style="width:100%" clearable>
                              <el-option label="男" value="1"></el-option>
                              <el-option label="女" value="2"></el-option>
                              <el-option label="未知" value="3"></el-option>
                          </el-select>
                      </td>
                      <td align="right">急诊标志</td>
                      <td>
                          <el-select v-model="searchobj.emerflag" clearable filterable style="width:100%">
                              <el-option label="急诊" value="1" key="1"></el-option>
                              <el-option label="常规" value="0" key="0"></el-option>
                          </el-select>
                      </td>
                          

                  </tr>
                  <!-- <tr>
                      <td align="right">申请项目</td>
                      <td colspan="3">
                          <el-select v-model="searchobj.reqitemcode" @dblclick.native="filterreqitem()" ref="refreqitemcode" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('reqitemcode','refreqitemcode',reqitemOption)">
                              <el-option v-for="(item, index) in reqitemOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td> 
                      
                      <td align="right" colspan="5">
                          <table style="width: 100%; font-size: 12px; white-space: nowrap;" border="0">
                              <tr>
                                  <td>
                                      <el-select v-model="searchobj.timetype" :clearable="false" ref="reftimetype"  style="width:100%">
                                          <el-option value="recieve" label="接收时间"></el-option>
                                          <el-option value="report"   label="报告时间"></el-option>
                                          <el-option value="recieve1"   label="签收时间"></el-option>
                                      </el-select>
                                  </td>
                                  <td>
                                      <el-time-picker v-model="searchobj.starttime" :clearable="true" placeholder="选择时间" style="width: 100%;" value-format="HH:mm:ss"></el-time-picker>
                                  </td>
                                  <td>至</td>
                                  <td>
                                      <el-time-picker v-model="searchobj.endtime" :clearable="true" placeholder="选择时间" style="width: 100%;" value-format="HH:mm:ss"></el-time-picker>
                                  </td>
                                  <td>
                                      <el-checkbox true-label="1" false-label="0" v-model="searchobj.iseliminate">剔除</el-checkbox>
                                  </td>
                              </tr>
                          </table>
                      </td>
                  </tr> -->
                  <tr>
                      <!-- <td align="right">统计项目</td>
                      <td colspan="3">
                          <div v-if="infoitem==''" @click="Btncountitem">
                              <span style="color:red;cursor:pointer;font-size:15px">点击该位置选择统计项目</span>
                          </div>
                          <div v-else>
                              <div @click="Btncountitem" style="width:100%;cursor:pointer;color:#409EFF"><u>{{infoitem}}</u></div>
                              <el-input v-model="infocode" readonly v-show="false"></el-input>
                          </div>
                      </td>
                      <td colspan='4' align="center" v-show="false">
                          <el-input v-model="searchobj.median" style="width:70px"></el-input>%分位数<el-input v-model="searchobj.median2" style="width:70px"></el-input>%分位数2
                      </td> -->
                      
                      <td align="right">接收时间</td>
                      <td>
                          <el-time-picker v-model="searchobj.starttime" placeholder="开始时间" style="height:25px;line-height:23px;width:100%" value-format="HH:mm" format='HH:mm'></el-time-picker>
                      </td>
                      <td>至</td>
                      <td>
                          <el-time-picker v-model="searchobj.endtime" placeholder="结束时间" style="height:25px;line-height:23px;width:100%" value-format="HH:mm" format='HH:mm'></el-time-picker>
                      </td>
                      
                      <td colspan="10" align="right">
                          <div>
                              <el-button @click.native="BtnQuery" v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
                              <!-- <el-button @click.native="BtnSort" icon="el-icon-sort">排序</el-button> -->
                              <el-button @click.native="BtnClear" icon="el-icon-close">清除</el-button>
                              <el-button @click.native="BtnExport" icon="el-icon-download">导出</el-button>
                              <!-- <el-button @click.native="BtnPrint(1)" icon="el-icon-printer">打印</el-button>
                              <el-button v-if="rptStyleSettingState" @click.native="BtnPrint(2)" class="el-icon-edit-outline">打印样式设计</el-button> -->
                          </div>
                      </td>
                  </tr>
              </table>
          </div>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <vxe-table :data.sync="tableData" :loading="loading" :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="xTable" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{ animat: false }" header-align="center"  :key="xTableKey" class="mytable-style">
                  <vxe-table-column field="pat_no" sortable title="病历号" width="90" show-overflow align="left"></vxe-table-column>
                  <vxe-table-column field="pat_name" sortable title="姓名" width="90" show-overflow align="left"></vxe-table-column>
                  <vxe-table-column field="pat_sexname" sortable title="性别" width="60" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="barcode" sortable title="条码号" width="120" show-overflow align="left"></vxe-table-column>
                  <vxe-table-column field="req_stat" sortable title="状态" width="100" show-overflow align="center" :formatter="formatterFun"></vxe-table-column>
                  <vxe-table-column field="emer_flag" sortable title="急诊标志" width="60" show-overflow align="center" :formatter="formatterFun"></vxe-table-column>
                  <vxe-table-column field="req_dt" sortable title="申请时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="sampled_dt" sortable title="采样时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="send_dt" sortable title="送出时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="send_dt1" sortable title="送达时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="recieve_dt" sortable title="接收时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="report_dt" sortable title="报告时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="input_dt" sortable title="录入时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_req_sampled" sortable title="申请到采样" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_sampled_recieve" sortable title="采样到接收" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_recieve_report" sortable title="接收到报告" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_sampled_send" sortable title="采样到送出" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_send_send1" sortable title="送出到送达" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_send1_recieve" sortable title="送达到接收" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_recieve_input" sortable title="接收到录入" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_input_report" sortable title="录入到报告" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="tat_req_report" sortable title="申请到报告" width="100" show-overflow align="center"></vxe-table-column>
                  
                  <vxe-table-column field="req_deptname" sortable title="申请科室" width="120" show-overflow align="left"></vxe-table-column>
                  <vxe-table-column field="doctorname" sortable title="申请医生" width="100" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="req_bedno" sortable title="床号" width="60" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="specimen_code" sortable title="标本类型" width="100" show-overflow align="left" :formatter="formatterFun"></vxe-table-column>
                  <vxe-table-column field="sampleno" sortable title="标本号" width="80" show-overflow align=""></vxe-table-column>
                  <vxe-table-column field="create_dt" sortable title="创建时间" width="125" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="pat_agestr" sortable title="年龄" width="60" show-overflow align="center"></vxe-table-column>
                  <vxe-table-column field="pat_diag" sortable title="临床诊断" width="100" show-overflow align="center"></vxe-table-column>
                   
              </vxe-table>
          </div>
      </div>

      <!--多选弹窗--->
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
      <!-- <el-dialog width="1100px" title="不合格标本信息查看" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="bunquaildlg" :destroy-on-close="true">
          <div style="height: 35px;text-align:right;padding-right:10px;">
              <el-button @click="ExportResult()" v-has="'PEXPORT'" icon="el-icon-download">导出</el-button>
          </div>
          <div style="height: 500px; width: 100%">
              <div style="height: 100%">
                  <vxe-table ref="reqtable" :data.sync="unquaildata" :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow resizable show-overflow size="mini" show-header-overflow :optimization="{ animat: false }" header-align="center">
                               <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                      <vxe-table-column field="req_groupna" sortable title="分单类别" width="100" show-overflow align="center"></vxe-table-column>
                      <vxe-table-column field="pat" sortable title="病人信息" align="center" width="180" show-overflow></vxe-table-column>
                      <vxe-table-column field="barcode" sortable title="条形码" align="center" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="sample_items" sortable title="申请项目(描述)" width="300" show-overflow></vxe-table-column>
                      <vxe-table-column field="tat_create_sampled" title="创建-采样" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_req_sampled" title="申请-采样" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_sampled_recieve" title="采样-接收" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_recieve_report" title="接收-报告" align="center" width="80px"></vxe-table-column>
                  <vxe-table-column field="create_dt" align="center" sortable title="创建时间" width="120px" show-overflow></vxe-table-column>
                      <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="recieve_dt" title="接收时间" width="120px" align="center"></vxe-table-column>
                      <vxe-table-column field="test_dt" title="上机时间" align="center" width="120px"></vxe-table-column>
                      <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="send_dt" align="center" sortable title="送出时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="recieve1_dt" title="工作组接收时间" width="100px"></vxe-table-column>
                      <vxe-table-column field="report_dt" title="报告时间" width="120"></vxe-table-column>
                      <vxe-table-column field="sampled_user" title="采样人" width="100"></vxe-table-column>
                      <vxe-table-column field="report_username" title="检验者" width="100"></vxe-table-column>
                      <vxe-table-column field="rechk_username" title="审核者" width="100"></vxe-table-column>
                  </vxe-table>
              </div>
          </div>
      </el-dialog> -->

      <!-- <el-dialog title="统计项目" :visible.sync="dialogcountItem" width="1000px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false">
         
          <div style="width:100%;height:400px;margin-top:5px">
              <div style="width:70%;height:100%;float:left;overflow:auto;border:1px solid #ccc;">
                  <div id='left_nav' class="left_nav">
                      <div @click="showseq=1" :class="showseq == 1 ? 'active' : ''" ref="left1">
                          1 申请信息
                      </div>
                      <div @click="showseq=2" :class="showseq == 2 ? 'active' : ''" ref="left2">
                          2 送检信息
                      </div>
                      <div @click="showseq=3" :class="showseq == 3 ? 'active' : ''" ref="left3">
                          3 检验信息
                      </div>
                      <div @click="showseq=4" :class="showseq == 4 ? 'active' : ''" ref="left4">
                          4 病人信息
                      </div>
                      <div @click="showseq=5" :class="showseq == 5 ? 'active' : ''" ref="left5">
                          5 检验日期
                      </div>
                  </div>
                  <div id='right_nav' class="right_nav">
                      <table class="table1style" style="width:100%;padding:10px">
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请类别','rp_reqtype')" v-model="rp_reqtype">申请类别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'标本类型','rp_specimen_code')" v-model="rp_specimen_code">标本类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请项目','rp_req_itemcode')" v-model="rp_req_itemcode">申请项目</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'分单类别','rp_req_groupid')" v-model="rp_req_groupid">分单类别</el-checkbox>
                              </td> 
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请日期','rp_req_dt')" v-model="rp_req_dt">申请日期</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'单价','rp_item_price')" v-model="rp_item_price">单价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'计价','rp_charge_flag')" v-model="rp_charge_flag">计价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'销售','rp_saleman')" v-model="rp_saleman">销售</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'采样用户','rp_sampled_username')" v-model="rp_sampled_username">采样用户</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==2">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医院','rp_hospitalname')" v-model="rp_hospitalname">送检医院</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检科室','rp_deptname')" v-model="rp_deptname">送检科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病区','rp_wardname')" v-model="rp_wardname">所在病区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医生','rp_doctorname')" v-model="rp_doctorname" v-has="'PQREQDOC'">送检医生</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验院区','rp_labhospitalname')" v-model="rp_labhospitalname">检验院区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验科室','rp_labdeptname')" v-model="rp_labdeptname">检验科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验组别','rp_labgroupname')" v-model="rp_labgroupname">检验组别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'报告单元','rp_rptunitname')" v-model="rp_rptunitname">报告单元</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'审核医生','rp_rechk_username')" v-model="rp_rechk_username">审核医生</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'性别','rp_pat_sexname')" v-model="rp_pat_sexname">性别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人类型','rp_pat_typecode')" v-model="rp_pat_typecode">病人类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人','rp_pat')" v-model="rp_pat">病人</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断','rp_pat_diag')" v-model="rp_pat_diag">诊断</el-checkbox>
                              </td>

                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断ICD','rp_pat_diag_icd')" v-model="rp_pat_diag_icd">诊断ICD</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人ID','rp_pat_id')" v-model="rp_pat_id">病人ID</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人号','rp_pat_no')" v-model="rp_pat_no">病人号</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'床位','rp_req_bedno')" v-model="rp_req_bedno">床位</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==5">
                              
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'年','rp_sampleyear')" v-model="rp_sampleyear">年</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'月','rp_samplemonth')" v-model="rp_samplemonth">月</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'日','rp_sampleday')" v-model="rp_sampleday">日</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'急诊标志','rp_emer_flag')" v-model="rp_emer_flag">急诊标志</el-checkbox>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
              <div style="width:29%;height:100%;float:left;margin-left:5px;overflow:auto;">
                  <vxe-table show-overflow ref="xTable2" height="auto" :data.sync="staticitemData" @current-change="dialogItemChange" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                      <vxe-table-column type="index" title="NO." width="50"></vxe-table-column>
                      <vxe-table-column field="countitem" title="统计项目" width="160" sortable header-align="center"></vxe-table-column>
                      <vxe-table-column field="countcode" title="统计代码" width="160" sortable header-align="center"></vxe-table-column>
                  </vxe-table>
              </div>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button icon="el-icon-top" @click="SetFirst()">首位</el-button>
              <el-button icon="el-icon-top-right" @click="SetUp()">上移</el-button>
              <el-button icon="el-icon-bottom-right" @click="SetDown()">下移</el-button>
              <el-button icon="el-icon-bottom" @click="SetLast()">末位</el-button>
              <el-button type="primary" @click="dialogcountItemsave">确 定</el-button>
              <el-button @click="dialogcountItem = false">取 消</el-button>
          </span>
      </el-dialog> -->
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS655",
  data() {
      return {
          bunquaildlg: false,
          unquaildata: [],
          oReqitemOption: [],
          reqstatOption: [
              { display: "申请", data: "0" },
              { display: "打印", data: "1" },
              { display: "打印复核", data: "12" },
              { display: "采样", data: "2" },
              { display: "护士站送出", data: "3" },
              { display: "已下载", data: "31" },
              { display: "检验科签收", data: "4" },
              { display: "部份报告(解除审核)", data: "5" },
              { display: "确认报告", data: "6" },
              { display: "剔回标本", data: "8" },
              { display: "作废", data: "9" },
              { display: "工作组签收", data: "41" },
              { display: "上机", data: "42" },
              { display: "组内交接", data: "43" },
              { display: "已分样", data: "44" },
              { display: "外送送出", data: "45" },
              { display: "特检组退回", data: "48" },
              { display: "申请单已被审核", data: "01" },
              { display: "申请单审核未通过", data: "02" },
              { display: "复审通过", data: "03" },
              { display: "复审未通过", data: "04" },
          ],
          dialogMultipleVisible: false,
          loading: false,
          option1: [],
          option2: [],
          rptStyleSettingState: false,  
          fieldname: "",
          tableData: [],
          chkcnt: 0,
          xTableKey: 0,
          multichktitle: "",
          datename: "接收日期",
          datetype: "recieve_dt",
          pattypeOption: [],
          deptOption: [],
          reqitemOption: [], //申请项目
          rptunitOption: [],
          labgroupOption: [],
          specimenOption: [],
          deptgroupOption: [], //deptcomb
          reqgroupOption: [],
          tableColumn: [],
          //以下为查询条件
          searchobj: {
              strdate: this.$pub.InitDateTime(),
              enddate: this.$pub.InitDateTime(),
              hospcode:"",
              reportusername:"",
              reqdocno:"",
              pattype: "",
              emerflag:"",
              rptunitid: "",
              reqdeptno:"",
              performdept:"",
              req_groupid:"",
              starttime:"",
              endtime:"",
              patsex:"",
              reqstat:"",
          },
          //以下为排序数组
          sortArr: [],
          SortTableColumn: [
              // { title: "细菌名称", field: "cp_samplecnt" },
              // { title: "细菌次数", field: "cp_cnt" },
              // { title: "细菌金额", field: "cp_amt" },
              // { title: "药敏项次", field: "cp_rs" },
              // { title: "药敏金额", field: "cp_redocnt" },
              // { title: "合计金额", field: "cp_amt" },
          ],
          hisrefcodelist: [],
          dialogcountItem:false,
          currentindex: -1,
          staticitemData: [],
          infoitem :"",
          infocode :"",
          showseq: 1,
          dialogcountItem:false, 
          hospOption:[],
          performdept:"",
          reportusername: "",
          reqdocname: "",
          performdeptname: "",
      };
  },
  created() {
      this.initOption();
      this.getOption();
      this.getLoginutype();
  },
  mounted() {},
  updated() {},
  methods: {
      handleCommand(name) {
          this.datename = name;
          if (name == "接收日期") {
              this.searchobj.datetype = "recieve_dt";
          } else if (name == "报告日期") {
              this.searchobj.datetype = "report_dt";
          } else {
              this.searchobj.datetype = "recieve1_dt";
          }
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          if (value != "close") {
              this.searchobj[name] = value;
          }
          this.dialogMultipleVisible = false;
      },
      getLoginutype() {
          let loginutype = this.$tool.getSession(this.$tool.loginutype);
          if (loginutype == "G") {
              this.rptStyleSettingState = true;
          }
      },
       
      getOption() {
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS655",
                  method: "post",
                  data: {
                      action: "getOptions",
                  },
              })
              .then((res) => {
                  //数据待后台返回
                  console.log(res);
                  this.reqitemOption = res.reqitemOption; //格式化时需要的全部的申请项目
                  this.oReqitemOption = res.reqitemOption;
                  this.reqgroupOption = res.reqgroupOption; //分单类别
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      async initOption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS6/LIS655",
                  method: "post",
                  data: {
                      action: "initoption",
                  },
              });
              this.pattypeOption = res.pattypeOption;
              this.deptOption = res.deptOption;
              this.hospOption = res.MulhospOption;
              this.doctorOption = res.doctorOption;
              this.rptunitOption = res.rptunitOption;
              this.rptunitGroupOption = res.rptunitGroupOption;
              this.wardOption = res.wardOption;
              this.labgroupOption = res.labgroupOption;
              this.specimenOption = res.specimenOption;
              this.userOption = res.userOption;
          } catch (e) {
              this.$message.warning(e);
          }
      },
      BtnQuery() {
          this.InitPage();
      },
       
      BtnClear() {
          this.searchobj = {
              strdate: this.$pub.InitDateTime(),
              enddate: this.$pub.InitDateTime(),
              hospcode:"",
              reportusername:"",
              reqdocno:"",
              pattype: "",
              emerflag:"",
              rptunitid: "",
              reqdeptno:"",
              performdept:"",
              req_groupid:"",
              starttime:"",
              endtime:"",
              patsex:"",
              reqstat:"",
          };
           
          this.tableData = [];
          this.staticitemData = [];
        
      },
      reportuserChange(code, name) {
          this.searchobj.reportusername = code;
          this.reportusername = name;
      },
      reqdocChange(code, name) {
          this.searchobj.reqdocno = code;
          this.reqdocname = name;
      },
      performdeptChange(code, name) {
          this.searchobj.performdept = code;
          this.performdeptname = name;
      },
      BtnExport() {
          // let options = {
          //     filename: "LIS655 TAT时间查询（按申请单）.csv",
          // };
          // this.$refs.xTable.exportCsv(options);
          this.tableColumn = [];
          let tableColumn = this.$refs.xTable.getColumns();
          tableColumn.forEach((item) => {
              this.tableColumn.push({ title: item.title, field: item.property });
          });
          let filtertxt = this.getExportFilter();
          this.$pub.exportTableExcel(this.tableData, this.tableColumn, "LIS655 TAT时间查询（按申请单）.xlsx", filtertxt, "统计条件：");
      },
      // 获取当前导出文件的所有查询条件
      getExportFilter() {
          let filtertxt = this.datename + ":" + XEUtils.toDateString(this.searchobj.strdate, "yyyy-MM-dd") + "至" + XEUtils.toDateString(this.searchobj.enddate, "yyyy-MM-dd") + "; ";
          if(this.searchobj.hospcode) filtertxt += "送检医院:" + this.getOptionName(this.hospOption.filter((item) =>  ("," + this.searchobj.hospcode + ",").indexOf("," + item.data + ",") > -1))+ "; ";
          if(this.searchobj.reportusername)  "检验医生:" + this.reportusername + "; ";
          if(this.searchobj.reqdocno)  "送检医生:" + this.reqdocname + "; ";
          if(this.searchobj.pattype) filtertxt += "病人类型:" + this.getOptionName(this.pattypeOption.filter((item) =>  ("," + this.searchobj.pattype + ",").indexOf("," + item.data + ",") > -1))+ "; ";
          if(this.searchobj.reqstat) filtertxt += "申请单状态:" + this.getReqStatName(this.searchobj.reqstat)+ "; ";
          if(this.searchobj.rptunitid) filtertxt += "报告单元:" + this.getOptionName(this.rptunitOption.filter((item) =>  ("," + this.searchobj.rptunitid + ",").indexOf("," + item.data + ",") > -1))+ "; ";
          if(this.searchobj.reqdeptno) filtertxt += "申请科室:" + this.getOptionName(this.deptOption.filter((item) =>  ("," + this.searchobj.reqdeptno + ",").indexOf("," + item.data + ",") > -1))+ "; ";
          if(this.searchobj.performdept)  "执行科室:" + this.performdeptname + "; ";
          if (this.searchobj.patsex) filtertxt += "性别:" + (this.searchobj.patsex == "1" ? "男" : this.searchobj.patsex == "2" ? "女" : "未知") + "; ";
          if (this.searchobj.emerflag) filtertxt += "急诊标志:" + (this.searchobj.emerflag == "0" ? "急诊" : "常规") + "; ";
          let recdttxt = "";
          if(this.searchobj.starttime) recdttxt += this.searchobj.starttime, "HH:mm";
          if(this.searchobj.endtime) recdttxt += "至" + this.searchobj.endtime, "HH:mm";
          if(recdttxt) filtertxt += "接收时间:" + recdttxt + "; ";
          return filtertxt;
      },
      getOptionName(option) {
          if (option && option.length > 0) {
              let optionname = "";
              option.forEach((item) => {
                  if(item.hasOwnProperty("display")) {
                      optionname += item.display + ",";
                  } else {
                      optionname += item.label + ",";
                  }
              });
              return optionname.substring(0, optionname.length - 1);
          } else {
              return "";
          }
      },
      getReqStatName(reqstat) {
          let reqstatname = "";
          switch(reqstat){
              case "0":
                  reqstatname = "申请";
                  break;
              case "1":
                  reqstatname = "打印";
                  break;
              case "2":
                  reqstatname = "采样";
                  break;
              case "3":
                  reqstatname = "护士站送出";
                  break;
              case "4":
                  reqstatname = "检验科签收";
                  break;
              case "01":
                  reqstatname = "申请单已被审核";
                  break;
              case "02":
                  reqstatname = "申请单审核未通过";
                  break;
              case "03":
                  reqstatname = "复审通过";
                  break;
              case "04":
                  reqstatname = "复审未通过";
                  break;
              case "12":
                  reqstatname = "打印复核";
                  break;
              case "31":
                  reqstatname = "已下载";
                  break;
              case "41":
                  reqstatname = "工作组签收";
                  break;
              case "42":
                  reqstatname = "上机";
                  break;
              case "43":
                  reqstatname = "组内交接";
                  break;
              case "44":
                  reqstatname = "已分样";
                  break;
              case "45":
                  reqstatname = "外送送出";
                  break;
          }
          return reqstatname;
      },
      BtnPrint(index) {
          // let columnArr = [
          //     { title: "细菌名称", property: "细菌名称" },
          //     { title: "细菌次数", property: "细菌次数" },
          //     { title: "细菌金额", property: "细菌金额" },
          //     { title: "药敏项次", property: "药敏项次" },
          //     { title: "药敏金额", property: "药敏金额" },
          //     { title: "合计金额", property: "合计金额" },
          // ];
          // columnArr.push({ title: "检验日期", property: "chkdate" });
          // columnArr.push({ title: "单元", property: "rptunitname" });
          // let str = JSON.stringify(columnArr);
          // str += "\r";
          // str += JSON.stringify(this.$refs.xTable.afterFullData);
          // let sql = btoa(encodeURIComponent(str));
          // if (index == "1") {
          //     jsObj.PrintCustomJsonReport("5033", sql, this.userno, "细菌工作量统计", "");
          // } else {
          //     jsObj.SetCustomJsonPrintConfig("5033", sql, this.userno, "细菌工作量统计");
          // }
      },
      rCellDblClick({ row, column }) {
          this.unquaildata = [];
          this.selrow = row;
          if (row.unquailcnt == "0") {
              this.$message.info("无不合格标本！");
              return false;
          }

          this.bunquaildlg = true;
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS652",
                  method: "post",
                  data: {
                      action: "queryDetail",
                      sqlstr: row.sqlstr,
                  },
              })
              .then((res) => {
                  if (res &&res!=""&& res.length > 0) {
                      this.unquaildata = res;
                  }
              })
              .catch((e) => {});
      },
      InitPage() { 
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS655",
                  method: "post",
                  timeout: 600000,
                  data: {
                      action: "InitPage", 
                      ...this.searchobj,
                  },
              })
              .then((response) => {
                  // let filedArr = this.infocode.split(",");
                  // let titleArr = this.infoitem.split(",");
                  // this.tableColumn = [];
                  // for (let index = 0; index < filedArr.length; index++) {
                  //     const title = titleArr[index];
                  //     const field = filedArr[index];
                  //     if (field != "") {
                  //         let width = "80px";
                  //         let align = "left";
                  //         if (["rp_sampleyear", "rp_samplemonth", "rp_pat_typecode", "rp_emer_flag"].includes(field)) width = "60px";
                  //         else if (["rp_req_deptno", "rp_labgroupname"].includes(field)) width = "120px";
                  //         else if (field == "rp_sample_items") width = "160px";
                  //         if (["rp_sampleyear", "rp_samplemonth", "rp_sampleday", "rp_pat_typecode", "rp_emer_flag"].includes(field)) align = "center";
                  //         this.tableColumn.push({ title: title, field: field, width: width, align: align });
                  //     }
                  // }
                  if (response.errcode == "1") {
                      this.loading = false;
                      this.tableData = response.Data;
                      this.xTableKey++;
                  } else {
                      this.$alert(response.errmsg, "信息");
                      this.loading = false;
                  }
              })
              .catch((e) => {
                  this.loading = false;
                  this.$message.warning(e);
              });
      },
       
      selectBlur(vcode, refcode, list) {
          let query = this.$refs[refcode].selectedLabel;
          var re = /^[0-9]+.?[0-9]*$/;
          if (!re.test(query)) {
              //不是数字,暂时不做任何事
              if (query.indexOf("[") == -1) {
                  //如果是输入值，此时没有光标选中传空值，如果是光标选中的选项不用处理自动传递
                  // this.$emit("change", "", "");
              }
          } else {
              //是数字
              if (query !== "") {
                  //let list = list.find((m) => m.data == query);
                  if (["refrptunitid", "reflabgroupid"].includes(refcode)) {
                      this.searchobj[vcode] = Number(query);
                  } else {
                      this.searchobj[vcode] = query;
                  }
                  this.$refs[refcode].blur();
              }
          }
      }, 

      formatterFun({ row, column, cellValue }) {
          if (column.property == "pat_sex") {
              if (cellValue == "1") {
                  return "男";
              } else if (cellValue == "2") {
                  return "女";
              } else {
                  return "";
              }
          } else if (column.property == "last_dt") {
              return XEUtils.toDateString(cellValue, "yyyy-MM-dd");
          } else if (column.property == "pat_typecode") {
              try {
                  let k = this.pattypeOption.find(m => m.data == cellValue).display;
                  if (k) {
                      return k;
                  } else {
                      return "";
                  }
              } catch (e) {}
          } else if (column.property == "emer_flag") {
              if (cellValue == "1") {
                  return "加急";
              } else {
                  return "常规";
              }
          } else if(column.property == "req_stat") {
              try {
                  let k = this.reqstatOption.find(m => m.data == cellValue).display;
                  if (k) {
                      return k;
                  } else {
                      return "";
                  }
              } catch (e) {}
          } else if (column.property == "specimen_code") {
              try {
                  let specimenname = this.specimenOption.find((m) => m.data == cellValue);
                  if (specimenname != undefined && specimenname != null) {
                      return specimenname.display;
                  } else {
                      return cellValue;
                  }
              } catch {
                  return cellValue;
              }
          }  else {
              return cellValue;
          }
      }, 
  },
};
</script>

<style scoped>
.pagetop {
  left: 0;
  right: 0;
  width: 100%;
  height: 105px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
  overflow-x: auto;
  overflow-x: overlay;
}
.pagecenter {
  position: absolute;
  top: 110px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}
.el-checkbox__label {
  padding: 0px;
}
.left_nav {
  width: 20%;
  height: 100%;
  border-right: 1px solid #ccc;
  padding: 0px 0px 0px 0px;
  float: left;
  display: inline;
}
.left_nav div {
  cursor: pointer;
  height: 40px;
  width: 100%;
  float: left;
  padding-left: 20px;
  line-height: 40px;
}
.left_nav .active {
  background-color: DeepSkyBlue;
}
.right_nav {
  width: 80%;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  float: left;
  display: inline;
}
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}
.table1style tr td {
  padding: 0px 2px 0px 5px;
}
::v-deep .mytable-style .vxe-footer--column.col-blue {
  color: blue !important;
  font-weight: bold;
}
::v-deep .mytable-style .vxe-body--row.row-blue {
  color: blue !important;
  font-weight: bold;
}
::v-deep .el-checkbox__label {
  padding-left: 0px;
}

::v-deep .el-icon-time {
  line-height: 18px !important;
}
::v-deep .el-range__close-icon {
  line-height: 18px !important;
}
::v-deep .el-range-editor--small .el-range-separator {
  line-height: 17px !important;
}
::v-deep .chktable tr td {
  padding-left: 20px;
}
::-webkit-scrollbar {
  width: 0px;
  height: 5px;
  border: 4px solid white;
}
::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
}
::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}
/* Buttons */
::-webkit-scrollbar-button:single-button {
  background-color: #bbbbbb;
  display: block;
  border-style: solid;
  height: 5px;
  width: 5px;
}
/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
  margin-right: 2px;
  border-width: 4px 4px 4px 0;
  border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:decrement:hover {
  border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}
/* Right */
::-webkit-scrollbar-button:horizontal:increment {
  margin-left: 2px;
  border-width: 4px 0 4px 4px;
  border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:increment:hover {
  border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}
</style>